# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgbase=espflash
pkgname=(espflash cargo-espflash)
pkgver=2.1.0
pkgrel=1
pkgdesc="Cargo subcommand for flashing Espressif devices over serial"
url='https://github.com/esp-rs/espflash'
arch=('loong64' 'x86_64')
license=('MIT' 'Apache-2.0')
depends=('libudev.so' 'libuv')
makedepends=('cargo' 'udev')
options=(!lto)
source=(https://github.com/esp-rs/${pkgbase}/archive/v${pkgver}/${pkgbase}-${pkgver}.tar.gz)
sha256sums=('85a62ee12949eeb9ed0cb186b87f88b1ff04eeabce5c4974cc24c304ed1bf960')
b2sums=('f4361c5c8f7d31d10cf22c67723847b1597c6ca307c67aa76e9b1620e9f3bb0a18b9f038f3370fb886c530958b40369b5970a51f06c7e30ba3825f036d054878')

prepare() {
  cd ${pkgbase}-${pkgver}
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd ${pkgbase}-${pkgver}
  cargo build --frozen --release
}

check() {
  cd ${pkgbase}-${pkgver}
  cargo test --frozen --workspace
}

package_espflash() {
  cd ${pkgbase}-${pkgver}
  install -Dm 755 -t "${pkgdir}/usr/bin" \
    target/release/espflash
}

package_cargo-espflash() {
  cd ${pkgbase}-${pkgver}
  install -Dm 755 -t "${pkgdir}/usr/bin" \
    target/release/cargo-espflash
}

# vim: ts=2 sw=2 et:
